<template>
	<view>
		<view class="tabBar">
			<view class="item" v-for="(item, index) in list" :key="index" @click="handleTab(item.pagePath)">
				<u-icon size="20" :name="current == item.index ? item.selectedIconPath : item.iconPath"></u-icon>
				<text :class="current == item.index ? 'action' : ''">{{ getStr('menu.' + item.text) }}</text>
			</view>
		</view>
		<!-- <view style="height:180rpx"></view> -->
	</view>
</template>
<script setup>
	import {ref,defineProps,onMounted} from 'vue'
	// import {created} from '@dcloudio/uni-app'
	const props = defineProps({
	  text: String,
		current:{
			type: Number,
			default: 0
		},
	})
	const isRender = ref(true)
	const list = ref([{
			"pagePath": "/pages/index/index",
			"iconPath": "/static/logo.png",
			"selectedIconPath": "/static/logo.png",
			"text": "home",
			"index": 0
		},
	])
	
	const handleTab = (url) => {
		uni.switchTab({
			url: url
		})
	}
	
	const getStr = (key) => {
		return uni.$t(key)
	}
	const setIsRender = () => {
		isRender.value = false
		setTimeout(() => {
			isRender.value = true
		}, 50)
	}
	
	onMounted(()=>{
		uni.hideTabBar(false)
		setIsRender()
	})
	
</script>

<style lang="scss">
	.tabBar {
		position: fixed;
		bottom: 0;
		// padding-bottom: constant(safe-area-inset-bottom);
		// padding-bottom: env(safe-area-inset-bottom);
		padding-bottom: 6px;
		box-sizing: content-box;
		left: 0;
		z-index: 99;
		width: 100%;
		height: 90rpx;
		background-color: #ffffff;
		display: flex;
		justify-content: center;
	}

	.tabBar .item {
		width: 20%;
		text-align: center;
		font-size: 20rpx;
		color: #999999;
		padding-top: 8rpx;
		display: flex;
		flex-direction: column;
		align-items: center;

		text {
			display: block;
			margin-top: 5rpx;
		}

		.action {
			color: #333333;
		}
	}
</style>